<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>校园淘物站注册</title>
    <link rel="stylesheet" href="[{$Think.const.CSS_URL}]register.css" media="all">
    <script src="[{$Think.const.STATIC_URL}]js/jquery.min.js"></script>
    <script>
        jQuery(document).ready(function ($) {
            $('.theme-popover-mask').fadeIn(100);
            $('.theme-popover').slideDown(200);
            $('.theme-poptit .close').click(function () {
                $('.theme-popover-mask').fadeOut(100);
                $('.theme-popover').slideUp(200);
                window.location.href = "[{$Think.const.APP_HOME_URL}]Index/index";
            })

        })
    </script>
</head>
<!--一个简单的JQ，用于验证新密码是否一致，和任意项不能为空,除了邮箱-->
<script type="text/javascript">
    $(document).ready(function () {
        $("#tj").click(function () {
            var a = $("#bcdl").attr('checked');
            if ($("#password").val() == '' || $("#question").val() == '' || $("#username").val() == '' || $("#fpassword").val() == '' || $("#answer").val() == '') {
                alert('除了邮箱，任意一项都不能为空');
                return false;
            }
            if ($('#password').val().length < '6') {
                alert('密码要大于等于6位');
                return false;
            }
            if ($("#password").attr("value") != $("#fpassword").attr("value")) {
                alert("密码不一致！");
                return false;
            }
            //如果不同意协议就无法注册
            if(a != 'checked'){
                alert("你不同意协议，你无权注册");
                return false;
            }
        });
    });
</script>
<!--一个简单的jq，用于ajax来发送查询用户是否存在-->
<script type="text/javascript">
    $(document).ready(function () {
        $("#username").blur(function () {
            var um = $("#username").val();
            $.ajax({
                type: "POST",
                url: "[{$Think.const.APP_HOME_URL}]User/check_user",
                data: "username=" + um,
                async: true, //默认为true 异步
                error: function () {
                    alert('error');
                },
                success: function (msg) {
                    if (msg == 'false') {
                        $("#yh").html('恭喜,该用户名可以注册');
                    } else {
                        $("#yh").html('对不起,该用户已存在');
                    }
                }
            });
        });
    });
</script>
<body>
<div class="theme-popover">
    <div class="theme-poptit">
        <a href="javascript:;" title="关闭" class="close">×</a>
        <h3>注册</h3>
    </div>
    <div class="theme-popbod dform">
        <form class="theme-signin" name="loginform" action="[{$Think.const.APP_HOME_URL}]User/register" method="post">
            <ol>
                <li><h4>注册用户</h4></li>
                <!--html5新特新-->
                <li><strong>用户名：</strong><input id="username" class="ipt" type="text" name="username" value=""
                                                placeholder="用户名" size="20"/><span id="yh"></span></li>
                <li><strong>密码：</strong><input id="password" class="ipt" type="password" name="password" value=""
                                               size="20"/></li>
                <li><strong>确认密码：</strong><input id="fpassword" class="ipt" type="password" name="fpassword" value=""
                                                 size="20"/></li>
                <li><strong>邮箱：</strong><input class="ipt" type="text" name="email" value="" size="20"/></li>
                <li><strong>密保问题：</strong><input id="question" class="ipt" type="text" name="question" value=""
                                                 size="20"/></li>
                <li><strong>答案：</strong><input id="answer" class="ipt" type="text" name="answer" value="" size="20"/>
                </li>
                <li>
                    <input id="tj" class="btn btn-primary" type="submit" value=" 注 册 "/>
                    &nbsp;&nbsp;&nbsp;&nbsp;<input id="bcdl" type="checkbox" checked="true"/><a
                        href="[{$Think.const.APP_HOME_URL}]User/registeragreement">同意注册协议</a>
                </li>
            </ol>
        </form>
    </div>
    <div class="clear"></div>
</div>
<div class="theme-popover-mask"></div>
</body>
</html>
